export function isAuth(tableName, key) {
    let role = localStorage.getItem("UserTableName");
    let menus = [{
        "backMenu": [{
            "child": [{
                "appFrontIcon": "cuIcon-goodsnew",
                "buttons": ["新增", "查看", "修改", "删除"],
                "menu": "家长",
                "menuJump": "列表",
                "tableName": "jiazhang"
            }], "menu": "家长管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-form",
                "buttons": ["新增", "查看", "修改", "删除", "查看评论"],
                "menu": "教师",
                "menuJump": "列表",
                "tableName": "jiaoshi"
            }], "menu": "教师管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-circle",
                "buttons": ["新增", "查看", "修改", "删除"],
                "menu": "课程类型",
                "menuJump": "列表",
                "tableName": "kechengleixing"
            }], "menu": "课程类型管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-addressbook",
                "buttons": ["查看", "修改", "删除", "查看评论"],
                "menu": "课程信息",
                "menuJump": "列表",
                "tableName": "kechengxinxi"
            }], "menu": "课程信息管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-flashlightopen",
                "buttons": ["查看", "修改", "删除"],
                "menu": "家教面试",
                "menuJump": "列表",
                "tableName": "jiajiaoyuyue"
            }], "menu": "家教面试管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-cardboard",
                "buttons": ["查看", "修改", "删除"],
                "menu": "更换教师",
                "menuJump": "列表",
                "tableName": "yuyuequxiao"
            }], "menu": "更换教师管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-qrcode",
                "buttons": ["查看", "修改", "删除"],
                "menu": "试教合同",
                "menuJump": "列表",
                "tableName": "shijiaohetong"
            }], "menu": "试教合同管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-phone",
                "buttons": ["查看", "修改", "删除"],
                "menu": "评价信息",
                "menuJump": "列表",
                "tableName": "pingjiaxinxi"
            }], "menu": "评价信息管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-cardboard",
                "buttons": ["查看", "修改", "删除"],
                "menu": "在线交流",
                "menuJump": "列表",
                "tableName": "zaixianjiaoliu"
            }], "menu": "在线交流管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-vip",
                "buttons": ["查看", "修改", "删除"],
                "menu": "我的课表",
                "menuJump": "列表",
                "tableName": "wodekebiao"
            }], "menu": "我的课表管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-qrcode",
                "buttons": ["查看", "修改", "删除", "查看评论", "新增"],
                "menu": "教师岗位",
                "menuJump": "列表",
                "tableName": "jiaoshigangwei"
            }], "menu": "教师岗位管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-newshot",
                "buttons": ["查看", "修改", "删除", "审核"],
                "menu": "应聘信息",
                "menuJump": "列表",
                "tableName": "yingpinxinxi"
            }], "menu": "应聘信息管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-link",
                "buttons": ["查看", "修改", "删除"],
                "menu": "轮播图管理",
                "tableName": "config"
            }, {
                "appFrontIcon": "cuIcon-news",
                "buttons": ["新增", "查看", "修改", "删除"],
                "menu": "公告信息",
                "tableName": "news"
            }, {
                "appFrontIcon": "cuIcon-form",
                "buttons": ["查看", "修改"],
                "menu": "关于我们",
                "tableName": "aboutus"
            }, {"appFrontIcon": "cuIcon-present", "buttons": ["查看", "修改"], "menu": "系统简介", "tableName": "systemintro"}],
            "menu": "系统管理"
        }],
        "frontMenu": [{
            "child": [{
                "appFrontIcon": "cuIcon-skin",
                "buttons": ["查看", "查看评论" ],
                "menu": "教师列表",
                "menuJump": "列表",
                "tableName": "jiaoshi"
            }], "menu": "教师模块"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-medal",
                "buttons": ["查看", "查看评论", "家教面试"],
                "menu": "课程信息列表",
                "menuJump": "列表",
                "tableName": "kechengxinxi"
            }], "menu": "课程信息模块"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-skin",
                "buttons": ["查看", "查看评论", "应聘"],
                "menu": "教师岗位列表",
                "menuJump": "列表",
                "tableName": "jiaoshigangwei"
            }], "menu": "教师岗位模块"
        }],
        "hasBackLogin": "是",
        "hasBackRegister": "否",
        "hasFrontLogin": "否",
        "hasFrontRegister": "否",
        "roleName": "管理员",
        "tableName": "users"
    }, {
        "backMenu": [{
            "child": [{
                "appFrontIcon": "cuIcon-flashlightopen",
                "buttons": ["查看", "修改", "删除", "试教合同", "更换教师", "评价信息"],
                "menu": "家教面试",
                "menuJump": "列表",
                "tableName": "jiajiaoyuyue"
            }], "menu": "家教面试管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-cardboard",
                "buttons": ["查看", "修改", "删除"],
                "menu": "更换教师",
                "menuJump": "列表",
                "tableName": "yuyuequxiao"
            }], "menu": "更换教师管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-qrcode",
                "buttons": ["查看", "修改", "删除"],
                "menu": "试教合同",
                "menuJump": "列表",
                "tableName": "shijiaohetong"
            }], "menu": "试教合同管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-phone",
                "buttons": ["查看", "修改", "删除"],
                "menu": "评价信息",
                "menuJump": "列表",
                "tableName": "pingjiaxinxi"
            }], "menu": "评价信息管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-cardboard",
                "buttons": ["查看", "修改", "删除"],
                "menu": "在线交流",
                "menuJump": "列表",
                "tableName": "zaixianjiaoliu"
            }], "menu": "在线交流管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-vip",
                "buttons": ["新增", "查看", "修改", "删除"],
                "menu": "我的课表",
                "menuJump": "列表",
                "tableName": "wodekebiao"
            }], "menu": "我的课表管理"
        }],
        "frontMenu": [{
            "child": [{
                "appFrontIcon": "cuIcon-skin",
                "buttons": ["查看", "查看评论" ],
                "menu": "教师列表",
                "menuJump": "列表",
                "tableName": "jiaoshi"
            }], "menu": "教师模块"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-medal",
                "buttons": ["查看", "查看评论", "家教面试"],
                "menu": "课程信息列表",
                "menuJump": "列表",
                "tableName": "kechengxinxi"
            }], "menu": "课程信息模块"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-skin",
                "buttons": ["查看", "查看评论", "应聘"],
                "menu": "教师岗位列表",
                "menuJump": "列表",
                "tableName": "jiaoshigangwei"
            }], "menu": "教师岗位模块"
        }],
        "hasBackLogin": "是",
        "hasBackRegister": "否",
        "hasFrontLogin": "是",
        "hasFrontRegister": "是",
        "roleName": "家长",
        "tableName": "jiazhang"
    }, {
        "backMenu": [{
            "child": [{
                "appFrontIcon": "cuIcon-form",
                "buttons": ["查看", "修改", "查看评论"],
                "menu": "教师",
                "menuJump": "列表",
                "tableName": "jiaoshi"
            }], "menu": "教师管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-addressbook",
                "buttons": ["新增", "查看", "修改", "删除", "查看评论"],
                "menu": "课程信息",
                "menuJump": "列表",
                "tableName": "kechengxinxi"
            }], "menu": "课程信息管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-flashlightopen",
                "buttons": ["查看", "审核"],
                "menu": "家教面试",
                "menuJump": "列表",
                "tableName": "jiajiaoyuyue"
            }], "menu": "家教面试管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-cardboard",
                "buttons": ["查看", "审核"],
                "menu": "更换教师",
                "menuJump": "列表",
                "tableName": "yuyuequxiao"
            }], "menu": "更换教师管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-qrcode",
                "buttons": ["查看", "审核"],
                "menu": "试教合同",
                "menuJump": "列表",
                "tableName": "shijiaohetong"
            }], "menu": "试教合同管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-phone",
                "buttons": ["查看", "审核"],
                "menu": "评价信息",
                "menuJump": "列表",
                "tableName": "pingjiaxinxi"
            }], "menu": "评价信息管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-cardboard",
                "buttons": ["查看", "审核"],
                "menu": "在线交流",
                "menuJump": "列表",
                "tableName": "zaixianjiaoliu"
            }], "menu": "在线交流管理"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-newshot",
                "buttons": ["查看", "修改", "删除"],
                "menu": "应聘信息",
                "menuJump": "列表",
                "tableName": "yingpinxinxi"
            }], "menu": "应聘信息管理"
        }],
        "frontMenu": [{
            "child": [{
                "appFrontIcon": "cuIcon-skin",
                "buttons": ["查看", "查看评论" ],
                "menu": "教师列表",
                "menuJump": "列表",
                "tableName": "jiaoshi"
            }], "menu": "教师模块"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-medal",
                "buttons": ["查看", "查看评论" ],
                "menu": "课程信息列表",
                "menuJump": "列表",
                "tableName": "kechengxinxi"
            }], "menu": "课程信息模块"
        }, {
            "child": [{
                "appFrontIcon": "cuIcon-skin",
                "buttons": ["查看", "查看评论", "应聘"],
                "menu": "教师岗位列表",
                "menuJump": "列表",
                "tableName": "jiaoshigangwei"
            }], "menu": "教师岗位模块"
        }],
        "hasBackLogin": "否",
        "hasBackRegister": "否",
        "hasFrontLogin": "是",
        "hasFrontRegister": "是",
        "roleName": "教师",
        "tableName": "jiaoshi"
    }];
    for (let i = 0; i < menus.length; i++) {
        if (menus[i].tableName == role) {
            for (let j = 0; j < menus[i].frontMenu.length; j++) {
                for (let k = 0; k < menus[i].frontMenu[j].child.length; k++) {
                    if (tableName == menus[i].frontMenu[j].child[k].tableName) {
                        let buttons = menus[i].frontMenu[j].child[k].buttons.join(',');
                        return buttons.indexOf(key) !== -1 || false
                    }
                }
            }
        }
    }
    return false;
}

/**
 *  * 获取当前时间（yyyy-MM-dd hh:mm:ss）
 *   */
export function getCurDateTime() {
    let currentTime = new Date(),
        year = currentTime.getFullYear(),
        month = currentTime.getMonth() + 1 < 10 ? '0' + (currentTime.getMonth() + 1) : currentTime.getMonth() + 1,
        day = currentTime.getDate() < 10 ? '0' + currentTime.getDate() : currentTime.getDate(),
        hour = currentTime.getHours(),
        minute = currentTime.getMinutes(),
        second = currentTime.getSeconds();
    return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
}

/**
 *  * 获取当前日期（yyyy-MM-dd）
 *   */
export function getCurDate() {
    let currentTime = new Date(),
        year = currentTime.getFullYear(),
        month = currentTime.getMonth() + 1 < 10 ? '0' + (currentTime.getMonth() + 1) : currentTime.getMonth() + 1,
        day = currentTime.getDate() < 10 ? '0' + currentTime.getDate() : currentTime.getDate();
    return year + "-" + month + "-" + day;
}
